home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / gnat1792.zip / gnat179b / t-adainc / a-ngcoty.ads < prev    next >
Text File  |  1994-05-19  |  7KB  |  143 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --   A D A . N U M E R I C S . G E N E R I C _ C O M P L E X _ T Y P E S    --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.3 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
  22. --                                                                          --
  23. ------------------------------------------------------------------------------
  24.  
  25. generic
  26.    type Real is digits <>;
  27.  
  28. package Ada.Numerics.Generic_Complex_Types is
  29.  
  30.    type Complex is record
  31.       Re, Im : Real'Base;
  32.    end record;
  33.  
  34.    type Imaginary is private;
  35.  
  36.    i : constant Imaginary;
  37.    j : constant Imaginary;
  38.  
  39.    function Re (X : Complex)   return Real'Base;
  40.    function Im (X : Complex)   return Real'Base;
  41.    function Im (X : Imaginary) return Real'Base;
  42.  
  43.    procedure Set_Re (X  : in out Complex;   Re : in Real'Base);
  44.    procedure Set_Im (X  : in out Complex;   Im : in Real'Base);
  45.    procedure Set_Im (X  :    out Imaginary; Im : in Real'Base);
  46.  
  47.    function Compose_From_Cartesian (Re, Im : Real'Base) return Complex;
  48.    function Compose_From_Cartesian (Re     : Real'Base) return Complex;
  49.    function Compose_From_Cartesian (Im     : Imaginary) return Complex;
  50.  
  51.    function Modulus (X     : Complex) return Real'Base;
  52.    function "abs"   (Right : Complex) return Real'Base renames Modulus;
  53.  
  54.    function Argument (X : Complex)                    return Real'Base;
  55.    function Argument (X : Complex; Cycle : Real'Base) return Real'Base;
  56.  
  57.    function Compose_From_Polar (
  58.      Modulus, Argument : Real'Base)
  59.      return Complex;
  60.  
  61.    function Compose_From_Polar (
  62.      Modulus, Argument, Cycle : Real'Base)
  63.      return Complex;
  64.  
  65.    function "+"       (Right : Complex) return Complex;
  66.    function "-"       (Right : Complex) return Complex;
  67.    function Conjugate (X     : Complex) return Complex;
  68.  
  69.    function "+"       (Left, Right : Complex) return Complex;
  70.    function "-"       (Left, Right : Complex) return Complex;
  71.    function "*"       (Left, Right : Complex) return Complex;
  72.    function "/"       (Left, Right : Complex) return Complex;
  73.  
  74.    function "**"      (Left : Complex; Right : Integer) return Complex;
  75.  
  76.    function "+"       (Right : Imaginary) return Imaginary;
  77.    function "-"       (Right : Imaginary) return Imaginary;
  78.    function Conjugate (X     : Imaginary) return Imaginary renames "-";
  79.    function "abs"     (Right : Imaginary) return Real'Base;
  80.  
  81.    function "+"       (Left, Right : Imaginary) return Imaginary;
  82.    function "-"       (Left, Right : Imaginary) return Imaginary;
  83.    function "*"       (Left, Right : Imaginary) return Real'Base;
  84.    function "/"       (Left, Right : Imaginary) return Real'Base;
  85.  
  86.    function "**"      (Left : Imaginary; Right : Integer) return Complex;
  87.  
  88.    function "<"       (Left, Right : Imaginary) return Boolean;
  89.    function "<="      (Left, Right : Imaginary) return Boolean;
  90.    function ">"       (Left, Right : Imaginary) return Boolean;
  91.    function ">="      (Left, Right : Imaginary) return Boolean;
  92.  
  93.    function "+"       (Left : Complex;   Right : Real'Base) return Complex;
  94.    function "+"       (Left : Real'Base; Right : Complex)   return Complex;
  95.    function "-"       (Left : Complex;   Right : Real'Base) return Complex;
  96.    function "-"       (Left : Real'Base; Right : Complex)   return Complex;
  97.    function "*"       (Left : Complex;   Right : Real'Base) return Complex;
  98.    function "*"       (Left : Real'Base; Right : Complex)   return Complex;
  99.    function "/"       (Left : Complex;   Right : Real'Base) return Complex;
  100.    function "/"       (Left : Real'Base; Right : Complex)   return Complex;
  101.  
  102.    function "+"       (Left : Complex;   Right : Imaginary) return Complex;
  103.    function "+"       (Left : Imaginary; Right : Complex)   return Complex;
  104.    function "-"       (Left : Complex;   Right : Imaginary) return Complex;
  105.    function "-"       (Left : Imaginary; Right : Complex)   return Complex;
  106.    function "*"       (Left : Complex;   Right : Imaginary) return Complex;
  107.    function "*"       (Left : Imaginary; Right : Complex)   return Complex;
  108.    function "/"       (Left : Complex;   Right : Imaginary) return Complex;
  109.    function "/"       (Left : Imaginary; Right : Complex)   return Complex;
  110.  
  111.    function "+"       (Left : Imaginary; Right : Real'Base) return Complex;
  112.    function "+"       (Left : Real'Base; Right : Imaginary) return Complex;
  113.    function "-"       (Left : Imaginary; Right : Real'Base) return Complex;
  114.    function "-"       (Left : Real'Base; Right : Imaginary) return Complex;
  115.  
  116.    function "*"       (Left : Imaginary; Right : Real'Base) return Imaginary;
  117.    function "*"       (Left : Real'Base; Right : Imaginary) return Imaginary;
  118.    function "/"       (Left : Imaginary; Right : Real'Base) return Imaginary;
  119.    function "/"       (Left : Real'Base; Right : Imaginary) return Imaginary;
  120.  
  121. private
  122.    type Imaginary is new Real'Base;
  123.  
  124.    i : constant Imaginary := 1.0;
  125.    j : constant Imaginary := 1.0;
  126.  
  127.    pragma Inline ("+");
  128.    pragma Inline ("-");
  129.    pragma Inline ("*");
  130.    pragma Inline ("<");
  131.    pragma Inline ("<=");
  132.    pragma Inline (">");
  133.    pragma Inline (">=");
  134.    pragma Inline ("abs");
  135.    pragma Inline (Compose_From_Cartesian);
  136.    pragma Inline (Conjugate);
  137.    pragma Inline (Im);
  138.    pragma Inline (Re);
  139.    pragma Inline (Set_Im);
  140.    pragma Inline (Set_Re);
  141.  
  142. end Ada.Numerics.Generic_Complex_Types;
  143.